package com.alingrad.android.test.cyborghuman;

import javax.microedition.khronos.opengles.GL10;

import com.alingrad.android.froyoengine.Game;
import com.alingrad.android.froyoengine.tree.MainLoop;
import com.alingrad.android.froyoengine.util.GLColor;

public class CyborgMainLoop extends MainLoop {
	private Cyborg mCyborg;
	private JumpObstacleManager mObstacles;
	
	public CyborgMainLoop() {
		mCyborg = new Cyborg();
		mObstacles = new JumpObstacleManager();
	}
	
	@Override
	public void load(GL10 gl) {
		mCyborg.load(gl);
		mObstacles.load(gl);
	}

	@Override
	public void update(long delta) {
		VirtualJoypad.get().update(delta);
		mCyborg.update(delta);
		mObstacles.update(delta);
		if (mObstacles.checkCollisionsWith(mCyborg) != null)
			Game.sRenderManager.setBackgroundColor(GLColor.RED);
		else
			Game.sRenderManager.setBackgroundColor(GLColor.BLACK);
	}

	@Override
	public boolean isAlive() {
		return true;
	}

}
